package com.example.xjtuse_pc.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.telephony.SmsManager;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.Toast;

/**
 * Created by XJTUSE-PC on 2016/3/24.
 */
public class BootComplateReceiver  extends BroadcastReceiver {
    private SharedPreferences sp;
    private TelephonyManager tm;
    @Override
    public void onReceive(Context context, Intent intent) {
        sp=context.getSharedPreferences("config", Context.MODE_PRIVATE);
        tm= (TelephonyManager) context.getSystemService(context.TELEPHONY_SERVICE);
        String spm=sp.getString("sim",null)+"qqs";
        Log.i("join",spm);
        String tmm=tm.getSimSerialNumber();
        if(spm.equals(tmm)){
            //SIM没有改变
        }else {
            //sim改变 发一个短信给安全号码
            Log.i("join","sim改变");
            Toast.makeText(context,"sim已经被改变",Toast.LENGTH_SHORT).show();
            SmsManager.getDefault().sendTextMessage(sp.getString("safephone", ""), null, "sim changing....", null, null);
        }
    }
}
